(function(){
	'use strict';
	angular.module('directive.switchingButton',[])
	.directive('switchingButton',switchingButton);
	function switchingButton(){
		return {
			restrict: 'E',
      scope: {
        exportUrl: '@',
        exportValue:'=',
        flag: '=',
      },
      template: templateString(),
      replace:true,
      link: PostLink
		};
		function PostLink(scope){
    	scope.clickBtnNgC = false;
			scope.changeTable = function(){
				scope.flag.show = 'table';
				scope.clickBtnNgC = true;
			};
			scope.changeView = function(){
				scope.flag.show = 'view';
				scope.clickBtnNgC = false;
			};
			scope.$watch('flag.show',function(n,o){
				n === 'table' ? scope.clickBtnNgC = true : scope.clickBtnNgC = false;
			});
    }
		function templateString(){
			return '<div class="menus" ng-show="flag.show === \'view\' || flag.show === \'table\'">'+
						'<md-button ng-class="{clcik_btn_bgColor: clickBtnNgC}" aria-label="列表" ng-click="changeTable()"  class="md-raised ico-btn">'+
            '<img src="images/tables.png"></md-button>'+
            '<md-button ng-class="{clcik_btn_bgColor: !clickBtnNgC}" aria-label="图表" ng-click="changeView()"  class="md-raised ico-btn">'+
            '<img src="images/charts.png"></md-button>'+
            '<form action="{{exportUrl}}" target="_black" method="post" style="display: initial;">'+
		        '<input type="hidden" name="data" value="{{exportValue}}">'+
		        '<md-button type="submit" class="md-raised">导出Excel</md-button>'+
		      	'</form>'+
					'</div>';
		}
	}
})();